<template>
  <div class="search">
    <f-form ref="form" :action="api.logistics" :form-key="this.formItem.logisticsId">
      <f-form-item label="公司名称" name="logisticsName" :required="true" :value="formItem.logisticsName"/>
      <f-form-item label="物流编号" name="logisticsNo" :required="true" :value="formItem.logisticsNo"/>
    </f-form>
  </div>
</template>

<script>
  export default {
    name: 'logisticsForm',
    props: {},
    data() {
      return {
        isAdd: true,//是否是添加模式
        loaded: false,//是否加载轮播图组件
        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem() {
        return {
          logisticsId: '',
          logisticsName: '',
          logisticsNo: ''
        }
      },
      //表单赋值
      setData(data) {
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        this.isAdd = true
        if (data && data.logisticsId) {
          this.$refs.form.getDetails({ logisticsId: data.logisticsId }, (data) => {
            this.formItem = data
            this.loaded = true
          })
          this.isAdd = false
        } else {
          this.loaded = true
        }
      },
      //文件上传回调
      uploadSuccess(fileUrl, file) {
        this.formItem.verUrl = fileUrl
      },
      //提交表单
      handleSubmit(callback) {
        this.$refs.form.submit(this.formItem,callback)
      },
      verCodeChange(val) {
        this.formItem.verCode = val
      }
    },
    created() {

    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
